﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>组织机构组件使用教程</title>
    <script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/szjt_org_toolkits.js" type="text/javascript"></script>
    <script type="text/javascript">
        // check for XPath implementation if(
        if (document.implementation.hasFeature("XPath", "3.0")) {
            // prototying the XMLDocument 
            XMLDocument.prototype.selectNodes = function (cXPathString, xNode) {
                if (!xNode) {
                    xNode = this;
                }
                var oNSResolver = this.createNSResolver(this.documentElement);
                var aItems = this.evaluate(cXPathString, xNode, oNSResolver,
                           XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
                var aResult = [];
                for (var i = 0; i < aItems.snapshotLength; i++) {
                    aResult[i] = aItems.snapshotItem(i);
                } return aResult;
            }
            // prototying the Element 
            Element.prototype.selectNodes = function (cXPathString) {
                if (this.ownerDocument.selectNodes) {
                    return this.ownerDocument.selectNodes(cXPathString, this);
                } else {
                    throw "For XML Elements Only";
                }
            }
        }
        var xmlDoc;
        var _xml = "<?xml version='1.0' encoding='utf-8' ?><ss><name>111</name><age>222</age><name>333</name><age>444</age></ss>";
        try //Internet Explorer
            {
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async = "false";
            xmlDoc.loadXML(_xml);
        }
        catch (e) {
            try //Firefox, Mozilla, Opera, etc.
               {
                parser = new DOMParser();
                xmlDoc = parser.parseFromString(_xml, "text/xml");
            }
            catch (e) {
                console.log(e.description);
            }
        }
        try {
            $(xmlDoc.selectNodes("ss/name")).eq(0).text("22222222");
            //alert((new XMLSerializer()).serializeToString(xmlDoc));
            //(new XMLSerializer()).serializeToString(xmlDoc);
        } catch (e) {
            console.log(e.description);
        }
    </script>
</head>
<body>
    <div style="text-align: center; font-size: 18px; color: Green; font-weight: bold;">
        组织机构组件使用教程</div>
    <div style="text-align: left; color: Orange; font-size: 14px;">
        1.取得单位选择列表</div>
</body>
</html>
